package com.conpany.project;

import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.IntFunction;
import java.util.stream.IntStream;

public class Zhoaqi {

    public static void main(String[] args) {

        String[] atp = {"Rafael Nadal", "Novak Djokovic",
                "Stanislas Wawrinka",
                "David Ferrer","Roger Federer",
                "Andy Murray","Tomas Berdych",
                "Juan Martin Del Potro"};
        List<String> players =  Arrays.asList(atp);

        // 以前的循环方式
        for (String player : players) {
            System.out.println(player + "; ");
        }

        players.forEach((player) ->System.out.println(player +""));
        System.out.println("---------");
        // 使用 lambda 表达式以及函数操作(functional operation)
        players.forEach((player) -> System.out.println(player + "; "));
        System.out.println("---------");
        // 在 Java 8 中使用双冒号操作符(double colon operator)
        players.forEach(System.out::println);




       // System.out.println(stringConsumer);

        //IntStream.
/*        for (int i = 0; i < 50; i++) {
            IntStream.range(0,3).mapToObj(Zhoaqi::create).forEach(Thread::start);
            System.out.println("************");
        }*/


    }
    private static Thread create(int index){

        return new Thread(()->{
            if (index == 0){
                Thread.yield();
            }
            System.out.println(index);
        });

    }

}
